function getPosition(a, b) {
    for (var c = 0; c < b.length; c++) if (a == b[c]) return c;
}

var parentTopHeight, broswerFlag, selectTree_id;

jQuery.fn.extend({
    selectSuggestionRender: function() {
        return this.each(function() {
            $(this).empty(), new jQuery.selectSuggestionBox(this);
        });
    }
}), selectTree_id = 1, jQuery.selectSuggestionBox = function(selectobj) {
    function nextPage() {
        var a = $suggestMain.find(".page_break a.current").next();
        null != a && null != $(a).attr("inum") && setAddPage($(a).attr("inum"));
    }
    function prevPage() {
        var a = $suggestMain.find(".page_break a.current").prev();
        null != a && null != $(a).attr("inum") && setAddPage($(a).attr("inum"));
    }
    function nextResult() {
        var b, a = $suggestMain.find(".list_city_container a").index($suggestMain.find(".list_city_container a.selected")[0]);
        $suggestMain.find(".list_city_container").children().removeClass("selected"), a += 1, 
        b = $suggestMain.find(".list_city_container a").index($suggestMain.find(".list_city_container a:visible").filter(":last")[0]), 
        a > b && (a = $suggestMain.find(".list_city_container a").index($suggestMain.find(".list_city_container a:visible").eq(0))), 
        $suggestMain.find(".list_city_container a").eq(a).addClass("selected");
    }
    function prevResult() {
        var b, a = $suggestMain.find(".list_city_container a").index($suggestMain.find(".list_city_container a.selected")[0]);
        $suggestMain.find(".list_city_container").children().removeClass("selected"), a -= 1, 
        b = $suggestMain.find(".list_city_container a").index($suggestMain.find(".list_city_container a:visible").filter(":first")[0]), 
        b > a && (a = $suggestMain.find(".list_city_container a").index($suggestMain.find(".list_city_container a:visible").filter(":last")[0])), 
        $suggestMain.find(".list_city_container a").eq(a).addClass("selected");
    }
    function loadCity() {
        var b, a = $suggestMain.find(".list_city_container");
        a.empty(), b = listData ? listData : $select.data("data"), b && ($.each(b[dataRoot], function(b, c) {
            var d;
            "pic" == $select.attr("renderMode") ? (d = $("<a href='javascript:void(0)' style='display:none;float:left;text-align:center;border:solid 1px #E8F4FF;margin:5px;'><div><img src='" + c.img + "'/></div><div style='text-align:center'>" + c.key + "</div></a>"), 
            $select.attr("itemHeight") && d.height(Number($select.attr("itemHeight"))), $select.attr("itemWidth") && d.width(Number($select.attr("itemWidth")))) : d = $("<a href='javascript:void(0)' style='display:none'><span>" + c.key + "</span></a>"), 
            d.attr("rel", c.value), d.data("data", c), a.append(d), d.bind("click", function() {
                setCurrent($(this).text(), $(this).attr("rel")), $select.data("selectedNode", $(this).data("data")), 
                $select.trigger("listSelect", {
                    relValue: $(this).attr("rel"),
                    relText: $(this).text()
                }), hideSuggest();
            }).bind("mouseover", function() {
                t_suggest_focus = !0;
            }).bind("mouseout", function() {
                t_suggest_focus = !1;
            });
        }), "pic" == $select.attr("renderMode") && a.after('<div class="clear"></div>')), 
        $suggestMain.find(".list_city_head").html(suggestTitle), setAddPage(1), setHeightSuggestion(), 
        showSuggest(), setTopSelect();
    }
    function queryCity() {
        var a, b, c, d, e, f, g, h;
        if ("local" == suggestMode) {
            if (hideMe(), a = $input.val().toLowerCase(), 0 == a.length) return showMultiList ? (showMe(), 
            hideSuggest(), setHeight()) : loadCity(), void 0;
            if (setHeightSuggestion(), showSuggest(), b = $suggestMain.find(".list_city_container"), 
            c = !1, d = new Array(), e = $select.data("data"), e && (finalData = e[dataRoot] ? e[dataRoot] : e, 
            $.each(finalData, function(b, e) {
                var f, g;
                if (e.suggest) for (f = e.suggest.split("|"), g = 0; g < f.length; g++) if (f[g].indexOf(a) >= 0) {
                    c = !0, d.push(e);
                    break;
                }
            })), c) {
                b.empty();
                for (f in d) g = d[f], "pic" == $select.attr("renderMode") ? (h = $("<a href='javascript:void(0)' style='display:none;float:left;text-align:center;border:solid 1px #E8F4FF;margin:5px;'><div><img src='" + g.img + "'/></div><div style='text-align:center'>" + g.key + "</div></a>"), 
                $select.attr("itemHeight") && h.height(Number($select.attr("itemHeight"))), $select.attr("itemWidth") && h.width(Number($select.attr("itemWidth")))) : h = $("<a href='javascript:void(0)' style='display:none'><span>" + g.key + "</span></a>"), 
                h.attr("rel", g.value), h.data("data", g), b.append(h), h.bind("click", function() {
                    setCurrent($(this).text(), $(this).attr("rel")), $select.data("selectedNode", $(this).data("data")), 
                    $select.trigger("listSelect", {
                        relValue: $(this).attr("rel"),
                        relText: $(this).text()
                    }), hideSuggest();
                }).bind("mouseover", function() {
                    t_suggest_focus = !0;
                }).bind("mouseout", function() {
                    t_suggest_focus = !1;
                });
                "pic" == $select.attr("renderMode") && b.after('<div class="clear"></div>'), $suggestMain.find(".list_city_head").html(suggestTitle), 
                setAddPage(1), setTopSelect();
            } else $suggestMain.find(".list_city_head").html("<span class='msg'>" + uncompile(quiLanguage.suggestion.errorMessage) + a + "</span>");
        } else currentQueryString = $.trim($input.val()), "" == currentQueryString ? hideSuggest() : currentQueryString.length >= minChars ? setTimeout(function() {
            loadList(currentQueryString);
        }, delay) : hideSuggest();
    }
    function loadList(a) {
        var b = buildUrl(a);
        $input.addClass("hintbox_loading"), $.post(b.url, b.params, function(a) {
            var d = $suggestMain.find(".list_city_container");
            d.empty(), a[dataRoot] && (a[dataRoot].length > 0 ? ($.each(a[dataRoot], function(b) {
                var e = $("<a href='javascript:void(0)' style='display:none' ><span>" + a[dataRoot][b].key + "</span></a>");
                e.attr("rel", a[dataRoot][b].value), e.data("data", a[dataRoot][b]), d.append(e), 
                e.bind("click", function() {
                    setCurrent($(this).text(), $(this).attr("rel")), $select.data("selectedNode", $(this).data("data")), 
                    $select.trigger("listSelect", {
                        relValue: $(this).attr("rel"),
                        relText: $(this).text()
                    }), hideSuggest();
                }).bind("mouseover", function() {
                    t_suggest_focus = !0;
                }).bind("mouseout", function() {
                    t_suggest_focus = !1;
                });
            }), $suggestMain.find(".list_city_head").html(suggestTitle), setAddPage(1), setTopSelect()) : ($suggestMain.find(".list_city_head").html("<span class='msg'>" + uncompile(quiLanguage.suggestion.errorMessage) + $input.val() + "</span>"), 
            setAddPage(1)), setHeightSuggestion(), "none" == $suggestMain[0].style.display && showSuggest()), 
            $input.removeClass("hintbox_loading");
        }, "json");
    }
    function buildUrl(a) {
        var b = {
            url: urlStr,
            params: {},
            queryString: ""
        };
        return b.params[matchName] = a, b.queryString = urlStr + "?" + matchName + "=" + a, 
        $.extend(!0, b.params, paramsObj), b;
    }
    function setAddPage(a) {
        $suggestMain.find(".list_city_container a").removeClass("selected"), $suggestMain.find(".list_city_container").children().each(function(b) {
            var c = b + 1;
            c > pageNum * (a - 1) && pageNum * a >= c ? $(this).css("display", "block") : $(this).hide();
        }), setTopSelect(), setAddPageHtml(a);
    }
    function setAddPageHtml(a) {
        var c, d, e, f, g, h, b = $suggestMain.find(".page_break");
        if (b.empty(), $suggestMain.find(".list_city_container").children().length > pageNum) {
            if (c = Math.ceil($suggestMain.find(".list_city_container").children().length / pageNum), 
            1 >= c) return;
            for (d = end = a, e = 0, f = 1; pageCount > e && pageCount > f; e++) d > 1 && (d--, 
            f++), c > end && (end++, f++);
            for (g = d; end >= g; g++) g == a ? b.append("<a href='javascript:void(0)' class='current' inum='" + g + "'>" + g + "</a") : b.append("<a href='javascript:void(0)' inum='" + g + "'>" + g + "</a");
            b.show();
        } else b.hide();
        h = b.find("a"), h.unbind("click"), h.unbind("mouseover"), h.unbind("mouseout"), 
        h.bind("click", function() {
            t_suggest_page_click = !0, null != $(this).attr("inum") && setAddPage($(this).attr("inum")), 
            $input.focus();
        }), h.bind("mouseover", function() {
            t_suggest_focus = !0;
        }).bind("mouseout", function() {
            t_suggest_focus = !1;
        }), setHeightSuggestion(), t_suggest_focus = !1;
    }
    function setTopSelect() {
        $suggestMain.find(".list_city_container").children().length > 0 && $suggestMain.find(".list_city_container").children(":visible").eq(0).addClass("selected");
    }
    function setHeight() {
        var a, b, c;
        $container.css({
            overflowY: "visible",
            overflowX: "visible"
        }), $container.width(""), $container.height(""), a = 200, a = window.document.documentElement.clientHeight - ($select.offset().top - $(window).scrollTop()) - 30, 
        $select.attr("multiListWidth") || (b = $container.width()), $container.css({
            overflowY: "auto",
            overflowX: "hidden"
        }), $select.attr("multiListWidth") ? $container.width(Number($select.attr("multiListWidth"))) : $container.width(b), 
        c = 0, $select.attr("multiListHeight") && (c = Number($select.attr("multiListHeight"))), 
        0 != c ? ($container.height(c), "top" == $select.attr("openDirection") ? $container.css({
            top: -c
        }) : "bottom" == $select.attr("openDirection") ? $container.css({
            top: selInputHeight
        }) : c > a ? $select.offset().top > c ? $container.css({
            top: -c
        }) : 100 > a && $select.offset().top > a && $select.offset().top > 100 ? $container.css({
            top: -c
        }) : $container.css({
            top: selInputHeight
        }) : $container.css({
            top: selInputHeight
        })) : "top" == $select.attr("openDirection") ? $select.offset().top > $container.height() ? $container.css({
            top: -$container.height()
        }) : ($container.height($mainCon.offset().top), $container.css({
            top: -$mainCon.offset().top
        })) : "bottom" == $select.attr("openDirection") ? a < $container.height() ? ($container.css({
            top: selInputHeight
        }), $container.height(a)) : $container.css({
            top: selInputHeight
        }) : a < $container.height() ? $select.offset().top > $container.height() ? $container.css({
            top: -$container.height()
        }) : 100 > a && $select.offset().top > a && $select.offset().top > 100 ? ($container.height($select.offset().top), 
        $container.css({
            top: -$select.offset().top
        })) : ($container.css({
            top: selInputHeight
        }), $container.height(a)) : $container.css({
            top: selInputHeight
        }), $select.attr("multiListWidth") || $container.width() < $input.width() && $container.width($input.width());
    }
    function setHeightSuggestion() {
        var a, b, c;
        $suggestMain.css({
            overflowY: "visible",
            overflowX: "visible"
        }), $suggestMain.width(""), $suggestMain.height(""), a = 200, a = window.document.documentElement.clientHeight - ($select.offset().top - $(window).scrollTop()) - 30, 
        $select.attr("boxWidth") || (b = $suggestMain.width()), $suggestMain.css({
            overflowY: "auto",
            overflowX: "hidden"
        }), $select.attr("boxWidth") ? $suggestMain.width(Number($select.attr("boxWidth"))) : $suggestMain.width(b), 
        c = 0, $select.attr("boxHeight") && (c = Number($select.attr("boxHeight"))), 0 != c ? ($suggestMain.height(c), 
        "top" == $select.attr("openDirection") ? $suggestMain.css({
            top: -c
        }) : "bottom" == $select.attr("openDirection") ? $suggestMain.css({
            top: selInputHeight
        }) : c > a ? $select.offset().top > c ? $suggestMain.css({
            top: -c
        }) : 100 > a && $select.offset().top > a && $select.offset().top > 100 ? $suggestMain.css({
            top: -c
        }) : $suggestMain.css({
            top: selInputHeight
        }) : $suggestMain.css({
            top: selInputHeight
        })) : "top" == $select.attr("openDirection") ? $select.offset().top > $suggestMain.height() ? $suggestMain.css({
            top: -$suggestMain.height()
        }) : ($suggestMain.height($mainCon.offset().top), $suggestMain.css({
            top: -$mainCon.offset().top
        })) : "bottom" == $select.attr("openDirection") ? a < $suggestMain.height() ? ($suggestMain.css({
            top: selInputHeight
        }), $suggestMain.height(a)) : $suggestMain.css({
            top: selInputHeight
        }) : a < $suggestMain.height() ? $select.offset().top > $suggestMain.height() ? $suggestMain.css({
            top: -$suggestMain.height()
        }) : 100 > a && $select.offset().top > a && $select.offset().top > 100 ? ($suggestMain.height($select.offset().top), 
        $suggestMain.css({
            top: -$select.offset().top
        })) : ($suggestMain.css({
            top: selInputHeight
        }), $suggestMain.height(a)) : $suggestMain.css({
            top: selInputHeight
        }), $select.attr("boxWidth") || $suggestMain.width() < inputWidth + selButtonWidth && $suggestMain.width(inputWidth + selButtonWidth);
    }
    function setupMainCon() {
        var a = $("<div></div>");
        return a.addClass("mainCon"), a;
    }
    function setupContainer() {
        var b = $("<div class='pop_city'><div class='pop_head'></div><ul class='list_label'></ul><div class='pop_city_container'></div></div>");
        return b.attr("id", "pop_city" + selectTree_id + "_container"), b;
    }
    function setupSuggestContainer() {
        var b = $("<div class='list_city'><div class='list_city_head'></div><div class='list_city_container'></div><div class='page_break'></div></div>");
        return b.attr("id", "suggest_city_" + selectTree_id + "_container"), b;
    }
    function setupInput(a) {
        var d, b = document.createElement("input"), c = $(b);
        return c.attr("id", "suggestion" + selectTree_id + "_input"), c.attr("type", "text"), 
        c.addClass(a.inputClass), d = !0, null != $select.attr("suggestable") && ("false" == $select.attr("suggestable") ? (d = !1, 
        showList = !0) : d = !0), d ? c.css("cursor", "text") : c.attr("readonly", "readonly"), 
        c.attr("autocomplete", "off"), ("disabled" == $select.attr("disabled") || "true" == $select.attr("disabled") || 1 == $select.attr("disabled")) && (c.attr("disabled", !0), 
        c.addClass("inputDisabled")), c;
    }
    function setupHidden() {
        var b = document.createElement("input"), c = $(b);
        return c.attr("type", "hidden"), null != $select.attr("name") && c.attr("name", $select.attr("name")), 
        c;
    }
    function setCurrent(a, b) {
        "" == b ? $input.css("color", "#aaa") : $input.css("color", "#000"), a == promptText ? $select.attr("relText", "") : $select.attr("relText", a), 
        $select.attr("relValue", b), $select.attr("value", $select.attr("relText")), $hidden.val(b), 
        $input.val(a);
    }
    function createOptions(a, b) {
        $container.find(".pop_head").text(popTitle), finalData = a[dataRoot] ? a[dataRoot] : a, 
        b ? $.each(finalDataTab, function(a, b) {
            0 == a ? (popContainer.append("<ul id='label_" + selectTree_id + a + "_container' class='current' data-type='" + b.name + "'></ul>"), 
            labelMain.append("<li><a id='label_" + selectTree_id + a + "' class='current' href='javascript:void(0)'>" + b.name + "</a></li>")) : (popContainer.append("<ul style='display:none' id='label_" + selectTree_id + a + "_container' data-type='" + b.name + "'></ul>"), 
            labelMain.append("<li><a id='label_" + selectTree_id + a + "' href='javascript:void(0)'>" + b.name + "</a></li>"));
            var c = a;
            $.each(b.tab, function(a, b) {
                var d = $("<li><a href='javascript:void(0)'>" + b.key + "</a></li>");
                d.width(colWidth), d.find("a").attr("rel", b.value), d.find("a").data("data", b), 
                $("#label_" + selectTree_id + c + "_container").append(d);
            });
        }) : (popContainer.append("<ul id='label_" + selectTree_id + "_container' class='current'></ul>"), 
        labelMain.remove(), $.each(finalData, function(a, b) {
            var c = $("<li><a href='javascript:void(0)'>" + b.key + "</a></li>");
            c.width(colWidth), c.find("a").attr("rel", b.value), c.find("a").data("data", b), 
            $("#label_" + selectTree_id + "_container").append(c);
        }));
    }
    function hideMe() {
        $container.hide(), $select.trigger("popClose");
    }
    function showMe() {
        showMultiList && (depth++, $select.css({
            zIndex: depth
        }), $container.show(), $select.trigger("popOpen"));
    }
    function hideSuggest() {
        $suggestMain.hide(), $select.trigger("suggestClose");
    }
    function showSuggest() {
        depth++, $select.css({
            zIndex: depth
        }), $suggestMain.show(), $select.trigger("suggestOpen");
    }
    function getCurrentSelected() {
        return $select.val();
    }
    function getCurrentValue() {
        return $input.val();
    }
    var selInputHeight, selButtonWidth, defaultSelWidth, fontSize, fontFamily, $parentThemeDom, curInputId, curButtonId, inFocus, t_pop_focus, t_suggest_focus, t_suggest_page_click, $select, popTitle, showMultiList, showList, promptText, selectedValue, pageNum, pageCount, colWidth, suggestTitle, errorMsg, iconSrc, autoCheck, errorAlert, currentQueryString, suggestMode, minChars, delay, matchName, $container, popContainer, labelMain, $suggestMain, $input, $hidden, $selBtn, inputWidth, $table, dataRoot, paramsStr, paramsObj, urlStr, finalDataList, finalDataTab, finalData, dataObj, dataObj2, tabData, listData, i, dataType, opt = {};
    if (opt.inputClass = opt.inputClass || "selectbox", opt.containerClass = opt.containerClass || "selectbox-tree", 
    opt.hoverClass = opt.hoverClass || "current", opt.currentClass = opt.selectedClass || "selected", 
    opt.debug = opt.debug || !1, selInputHeight = 24, selButtonWidth = 24, defaultSelWidth = 0, 
    fontSize = 12, fontFamily = "宋体", splitMode ? (null != $select.attr("selInputHeight") && (selInputHeight = Number($select.attr("selInputHeight"))), 
    null != $select.attr("selButtonWidth") && (selButtonWidth = Number($select.attr("selButtonWidth")))) : ($parentThemeDom = $(window.top.document.getElementById("theme")), 
    null != $parentThemeDom.attr("selInputHeight") && (selInputHeight = Number($parentThemeDom.attr("selInputHeight"))), 
    null != $parentThemeDom.attr("selButtonWidth") && (selButtonWidth = Number($parentThemeDom.attr("selButtonWidth"))), 
    null != $parentThemeDom.attr("defaultSelWidth") && (defaultSelWidth = Number($parentThemeDom.attr("defaultSelWidth"))), 
    fontSize = top.getFontSize(), fontFamily = top.getFontFamily()), selectTree_id++, 
    curInputId = "0_input", curButtonId = "0_button", inFocus = !1, t_pop_focus = !1, 
    t_suggest_focus = !1, t_suggest_page_click = !1, $select = $(selectobj), $select.addClass("mainCon"), 
    "right" == $select.attr("inputAlign") && $select.css("float", "right"), popTitle = uncompile(quiLanguage.suggestion.popTitle), 
    null != $select.attr("popTitle") && (popTitle = $select.attr("popTitle")), showMultiList = !1, 
    (1 == $select.attr("showMultiList") || "true" == $select.attr("showMultiList")) && (showMultiList = !0), 
    showList = !1, (1 == $select.attr("showList") || "true" == $select.attr("showList")) && (showList = !0), 
    promptText = uncompile(quiLanguage.suggestion.promptText2), null != $select.attr("prompt") ? promptText = $select.attr("prompt") : (showList || showMultiList) && (promptText = uncompile(quiLanguage.suggestion.promptText2)), 
    selectedValue = "", $select.attr("selectedValue") && (selectedValue = $select.attr("selectedValue")), 
    pageNum = 10, null != $select.attr("pageNum") && (pageNum = Number($select.attr("pageNum"))), 
    pageCount = 5, null != $select.attr("pageCount") && (pageCount = Number($select.attr("pageCount"))), 
    colWidth = 50, null != $select.attr("colWidth") && (colWidth = Number($select.attr("colWidth"))), 
    suggestTitle = uncompile(quiLanguage.suggestion.promptText2), "true" == $select.attr("showList") && (suggestTitle = uncompile(quiLanguage.suggestion.suggestTitle)), 
    null != $select.attr("suggestTitle") && (suggestTitle = $select.attr("suggestTitle")), 
    errorMsg = uncompile(quiLanguage.suggestion.errorMsg), null != $select.attr("errorMsg") && (errorMsg = $select.attr("errorMsg")), 
    null != $select.attr("iconSrc") && (iconSrc = $select.attr("iconSrc")), autoCheck = !0, 
    (0 == $select.attr("autoCheck") || "false" == $select.attr("autoCheck")) && (autoCheck = !1), 
    errorAlert = !1, (1 == $select.attr("errorAlert") || "true" == $select.attr("errorAlert")) && (errorAlert = !0), 
    currentQueryString = "", suggestMode = "local", "remote" == $select.attr("suggestMode") && (suggestMode = "remote"), 
    minChars = 1, null != $select.attr("minChars") && (minChars = Number($select.attr("minChars"))), 
    delay = 0, null != $select.attr("delay") && (delay = Number($select.attr("delay"))), 
    matchName = "q", null != $select.attr("matchName") && (matchName = $select.attr("matchName")), 
    $container = setupContainer(opt), popContainer = $container.find(".pop_city_container"), 
    labelMain = $container.find(".list_label"), $suggestMain = setupSuggestContainer(opt), 
    $input = setupInput(opt), $hidden = setupHidden(opt), $selBtn = $("<input type='button' value=' ' class='selBtn'/>"), 
    ("disabled" == $select.attr("disabled") || "true" == $select.attr("disabled") || 1 == $select.attr("disabled")) && ($selBtn.attr("disabled", !0), 
    $selBtn.addClass("selBtn_disabled"), $input.addClass("selectbox_disabled")), $selBtn.attr("id", "selectTree" + selectTree_id + "_button"), 
    inputWidth = 97, null != $select.attr("selWidth") ? inputWidth = Number($select.attr("selWidth")) - selButtonWidth : 0 != defaultSelWidth && (inputWidth = defaultSelWidth - selButtonWidth), 
    $input.width(inputWidth), $input.css("fontFamily", fontFamily), $input.css("fontSize", fontSize), 
    null != $select.attr("inputHeight") && (selInputHeight = Number($select.attr("inputHeight")), 
    $input.height(selInputHeight)), $table = $('<table cellspacing="0" cellpadding="0" style="border-style:none;"><tr><td class="ali01" style="border-style:none;padding:0;margin:0;"></td><td class="ali01" style="border-style:none;;padding:0;margin:0;"></td></tr></table>'), 
    $table.find("td").eq(0).append($input), $table.find("td").eq(1).append($selBtn), 
    $select.append($table), $select.append($container), $select.append($suggestMain), 
    $select.append($hidden), $container.hide(), $suggestMain.hide(), dataRoot = "list", 
    $select.attr("dataRoot") && (dataRoot = $select.attr("dataRoot")), paramsStr = $select.attr("params"), 
    paramsObj = {}, paramsStr) try {
        paramsObj = JSON.parse(paramsStr);
    } catch (e) {
        paramsObj = [], alert(uncompile(quiLanguage.suggestion.paramErrorMessage));
    }
    if (urlStr = $select.attr("url"), "local" == suggestMode) if (dataObj = "", dataObj2 = $select.data("data"), 
    tabData = null, null != $select.data("tab") && (tabData = $select.data("tab"), finalDataTab = tabData[dataRoot] ? tabData[dataRoot] : tabData), 
    listData = null, null != $select.data("list") && (listData = $select.data("list"), 
    finalDataList = listData[dataRoot] ? listData[dataRoot] : listData), dataObj2) {
        if (showMultiList && createOptions(dataObj2, tabData), "" == selectedValue) ("" == $.trim($input.val()) || $.trim($input.val()) == promptText) && $input.val(promptText).css("color", "#aaa"), 
        $select.attr("relText", ""), $select.attr("relValue", ""), $select.attr("value", ""), 
        $hidden.val(""); else if (listData = $select.data("data")) for (finalData = listData[dataRoot] ? listData[dataRoot] : listData, 
        i = 0; i < finalData.length; i++) if (finalData[i].value == selectedValue) {
            setCurrent(finalData[i].key, selectedValue), $select.data("selectedNode", finalData[i]);
            break;
        }
    } else urlStr && (dataType = "json", $select.attr("dataType") && (dataType = $select.attr("dataType")), 
    $.ajax({
        url: $select.attr("url"),
        dataType: dataType,
        data: paramsObj,
        error: function() {
            alert(uncompile(quiLanguage.suggestion.urlErrorMessage));
        },
        success: function(data) {
            var myData, listData, i;
            if (myData = "text" == dataType ? eval("(" + data + ")") : data, $select.data("data", myData), 
            dataObj = myData, showMultiList && createOptions(myData, tabData), "" == selectedValue) ("" == $.trim($input.val()) || $.trim($input.val()) == promptText) && $input.val(promptText).css("color", "#aaa"), 
            $select.attr("relText", ""), $select.attr("relValue", ""), $select.attr("value", ""), 
            $hidden.val(""); else if (listData = $select.data("data")) for (finalData = listData[dataRoot] ? listData[dataRoot] : listData, 
            i = 0; i < finalData.length; i++) if (finalData[i].value == selectedValue) {
                setCurrent(finalData[i].key, selectedValue), $select.data("selectedNode", finalData[i]);
                break;
            }
        }
    })); else $select.attr("relValue") && "" != $select.attr("relValue") ? ($hidden.val($select.attr("relValue")), 
    $input.val($select.attr("relText")).css("color", "#000000")) : (("" == $.trim($input.val()) || $.trim($input.val()) == promptText) && $input.val(promptText).css("color", "#aaa"), 
    $select.attr("relText", ""), $select.attr("relValue", ""), $select.attr("value", ""), 
    $hidden.val(""));
    $input.focus(function() {
        return t_suggest_page_click ? (t_suggest_page_click = !1, !0) : ($.trim($(this).val()) == promptText && $(this).val("").css("color", "#000"), 
        void 0);
    }).click(function() {
        if (t_suggest_page_click) return t_suggest_page_click = !1, void 0;
        if ("local" == suggestMode) if (hideSuggest(), setHeight(), showMultiList) showMe(); else if (showList) return loadCity(), 
        void 0;
    }).blur(function() {
        0 == t_pop_focus && hideMe(), 0 == t_suggest_focus && hideSuggest(), "" == $.trim($input.val()) || $.trim($input.val()) == promptText ? (setCurrent(promptText, ""), 
        $select.data("selectedNode", {}), setTimeout(function() {
            $select.trigger("validate2");
        }, 500)) : ("local" == suggestMode ? autoCheck ? setTimeout(function() {
            var a, b, c, d;
            if ("none" == $suggestMain[0].style.display && "none" == $container[0].style.display && (a = $input.val(), 
            b = !1, c = $select.data("data"))) {
                for (finalData = c[dataRoot] ? c[dataRoot] : c, d = 0; d < finalData.length; d++) if (finalData[d].key == a) {
                    setCurrent(a, finalData[d].value), $select.data("selectedNode", finalData[d]), b = !0;
                    break;
                }
                if (!b) {
                    if (errorAlert) try {
                        top.Dialog.alert(errorMsg);
                    } catch (e) {
                        alert(errorMsg);
                    }
                    setCurrent(promptText, ""), $select.data("selectedNode", {});
                }
            }
        }, 500) : $select.attr("relText", $input.val()) : $select.attr("relText", $input.val()), 
        setTimeout(function() {
            $select.trigger("validate", $.trim($input.val()));
        }, 500));
    }), $selBtn.focus(function() {
        return t_suggest_page_click ? (t_suggest_page_click = !1, !0) : ($.trim($(this).val()) == promptText && $(this).val("").css("color", "#000"), 
        void 0);
    }).click(function() {
        if (t_suggest_page_click) return t_suggest_page_click = !1, void 0;
        if ("local" == suggestMode) {
            if (hideSuggest(), setHeight(), !showMultiList) return loadCity(), void 0;
            showMe();
        }
    }).blur(function() {
        0 == t_pop_focus && hideMe(), 0 == t_suggest_focus && hideSuggest(), "" == $.trim($input.val()) || $.trim($input.val()) == promptText ? (setCurrent(promptText, ""), 
        $select.data("selectedNode", {}), setTimeout(function() {
            $select.trigger("validate2");
        }, 500)) : ("local" == suggestMode ? autoCheck && setTimeout(function() {
            var a, b, c, d;
            if ("none" == $suggestMain[0].style.display && "none" == $container[0].style.display && (a = $input.val(), 
            b = !1, c = $select.data("data"))) {
                for (finalData = c[dataRoot] ? c[dataRoot] : c, d = 0; d < finalData.length; d++) if (finalData[d].key == a) {
                    setCurrent(a, finalData[d].value), $select.data("selectedNode", finalData[d]), b = !0;
                    break;
                }
                if (!b) {
                    if (errorAlert) try {
                        top.Dialog.alert(errorMsg);
                    } catch (e) {
                        alert(errorMsg);
                    }
                    setCurrent(promptText, ""), $select.data("selectedNode", {});
                }
            }
        }, 500) : $select.attr("relText", $input.val()), setTimeout(function() {
            $select.trigger("validate", $.trim($input.val()));
        }, 500));
    }), labelMain.find("a").bind("click", function() {
        $input.focus(), t_pop_focus = !0;
        var a = $(this).attr("id");
        labelMain.find("li a").removeClass("current"), $(this).addClass("current"), popContainer.find("ul").hide(), 
        $("#" + a + "_container").show();
    }), popContainer.find("a").bind("click", function() {
        setCurrent($(this).text(), $(this).attr("rel")), $select.data("selectedNode", $(this).data("data")), 
        $select.trigger("multiListSelect", $(this).attr("rel"), $(this).text()), hideMe();
    }), $container.mouseover(function() {
        t_pop_focus = !0;
    }).mouseout(function() {
        t_pop_focus = !1;
    }), $input.keydown(function(a) {
        hideMe(), a = window.event || a;
        var b = a.keyCode || a.which || a.charCode;
        37 == b ? prevPage() : 39 == b ? nextPage() : 38 == b ? prevResult() : 40 == b && nextResult();
    }).keypress(function(a) {
        var b, c;
        a = window.event || a, b = a.keyCode || a.which || a.charCode, 13 == b && $suggestMain.find(".list_city_container a.selected").length > 0 && (c = $suggestMain.find(".list_city_container a.selected"), 
        setCurrent(c.text(), c.attr("rel")), $select.data("selectedNode", c.data("data")), 
        $select.trigger("listSelect", {
            relValue: c.attr("rel"),
            relText: c.text()
        }), hideSuggest());
    }).keyup(function(a) {
        a = window.event || a;
        var b = a.keyCode || a.which || a.charCode;
        13 != b && 37 != b && 39 != b && 9 != b && 38 != b && 40 != b && ("false" == $select.attr("suggestable") || queryCity());
    });
}, String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
};